﻿using BLL.DTO.LogDto;
using DAL.Service;
using Helper;
using HZY.Framework.DependencyInjection;
using Mapster;
using Model;
using Model.Entity;
using Model.EntityInfo;

namespace BLL.Manager
{
    public class LogManager : IScopedSelfDependency
    {
        private readonly LogService _logService;

        public LogManager(LogService logService)
        {
            _logService = logService;
        }

        /// <summary>
        /// 获取日志列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<BaseResult<ResPageData<LogInfoModel>>> GetLogListAsync(LogListDto query)
        {
            return await _logService.GetLogListAsync(query.Content, query.Page, query.PageSize, query.StartDate, query.EndDate, query.Level);
        }
        /// <summary>
        /// 新增日志
        /// </summary>
        /// <param name="LogDto"></param>
        /// <returns></returns>
        public async Task<BaseResult<string>> CreateLogAsync(LogAddDto LogDto)
        {
            Console.WriteLine($"新增日志:{LogDto.Content}");
            LogEntity LogEntity = LogDto.Adapt<LogEntity>();
            LogEntity.CreatedAt = new DateTime();
            return await _logService.CreateLogAsync(LogEntity);
        }

    }
}
